package com.love.cloud.auth.service.impl;

import com.love.cloud.admin.api.dto.UserInfo;
import com.love.cloud.admin.api.provider.RemoteUserProvider;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * 用户详细信息
 *
 * @author lengleng
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class MyUserDetailsServiceImpl extends BaseUserDetailServiceImpl {
	@DubboReference(version = "1.0.0", timeout = 30000)
	private RemoteUserProvider remoteUserProvider;

	@Override
	protected UserInfo getUser(String userName) {
		UserInfo info = remoteUserProvider.info(userName);
		if(info==null){
			throw new UsernameNotFoundException("未查询到该用户");
		}
		return info;
	}
}
